<?php 
	require_once '../function.php';

	$user = xiu_get_current_user_admin();

	// 查询所有文章数量
	$posts_num = xiu_fetch_db_one('select count(1) as posts from posts;');
	
	// 草稿的数量,数据库中,status=1代表已发布,status=2代表草稿
	$draft_num = xiu_fetch_db_one("select count(1) as draft from posts where status = '1';");

	// 分类数量
	$categories_num = xiu_fetch_db_one('select count(1) as categories from categories;');
	
	// 评论数量
	$comments_num = xiu_fetch_db_one('select count(1) as comments from comments;');

	// 待审核评论数量,评论状态为1代表已经发布,评论状态为2代表待审核
	$comments_audit_num = xiu_fetch_db_one("select count(1) as audit from comments where status = '2';");
	

 ?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="/static/vendors/bootstrap4.6/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="/static/css/admin.css">
</head>
<body>
	<div class="main">
		<?php include './inc/navbar.php'; ?>
		<div class="container-fluid">
			<div class="jumbotron text-center">
			 	<h1 class="display-4">One Belt, One Road</h1>
			 	<p>Thoughts, stories and ideas.</p>
			 	<a class="btn btn-lg" href="/admin/post-ad.php" role="button">写文章</a>
			</div>
			<div class="row">
				<div class="col-md-3">
					<div class="panel panel-default">
						<div class="panel-head">
							站点内容统计：
						</div>
						<ul class="list-group">
							<li class="list-group-item">
								<strong><?php echo $posts_num['posts']; ?></strong>&nbsp;篇文章(&nbsp;<strong><?php echo $draft_num['draft'] ?></strong>&nbsp;篇草稿)
							</li>
							<li class="list-group-item">
								<strong><?php echo $categories_num['categories'] ?></strong>&nbsp;个分类
							</li>
							<li class="list-group-item">
								<strong><?php echo $comments_num['comments'] ?></strong>&nbsp;条评论（&nbsp;<strong><?php echo $comments_audit_num['audit']; ?></strong>&nbsp;条待审核）
							</li>
							<li class="list-group-item">
								访问人数：103
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<?php $current_page = 'index' ?>
	<?php include './inc/asid.php'; ?>
	<script src="/static/vendors/jQuery.js"></script>
	<script src="/static/vendors/bootstrap4.6/js/bootstrap.js"></script>
</body>
</html>